//
//  BaseTableViewController.swift
//  我的微博练习
//
//  Created by zhangguo on 15/10/8.
//  Copyright © 2015年 zhangguo. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

//    记录游客登录状态
    var userLogin = UserAccount.userLogon
    //访客视图
    var visitorView:viewLogingView?
    //判断是否登陆更换视图
    override func loadView() {
        userLogin ? super.loadView() : setUpView()
    }
    
    //访客视图
    func setUpView(){
        
        visitorView = viewLogingView()
        visitorView?.delegate = self
        view = visitorView
        
        //设置状态栏
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
    }
    
    //加载授权视图
    func visitorLoginViewWillLogin() {
        
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
        
        //设置状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
    }
}
